package javaEE65_day02.StudentTeacherManger.service;

import javaEE65_day02.StudentTeacherManger.dao.TeacherDao;
import javaEE65_day02.StudentTeacherManger.domian.Teacher;


public class TeacherService {
    //添加教师信息
    public static boolean addTeacher(Teacher tea) {
        //将rea对象传递给库管类中的addTeacher方法并接收反馈的结果
        return TeacherDao.addTeacher(tea);
    }
    //判断教师工号是否存在
    public static boolean isExists(String id) {
        //调用库管类中的findAllTeacher方法获取保存教师信息的容器
        Teacher[] teach = TeacherDao.findAllTeacher();
        //判断工号是否已经存在
        for (int i = 0; i < teach.length; i++) {
            Teacher teacher = teach[i];
            if ((teacher != null )&& (teacher.getJobNumber().equals(id))){
                //工号存在
                return true;
            }
        }
        //工号不存在
        return false;
    }
    //删除教师信息
    public static boolean deleteTeacherById(String id ) {
        //将工号传递给库管类中的deleteTeacherById方法并接收反馈的结果
        return TeacherDao.deleteTeacherById(id);

    }
    //修改教师信息
    public static boolean updateTeacher(String id, Teacher teacher) {
        //将工号传递给库管类中的updateTeacher方法并接收返回的结果
        return TeacherDao.updateTeacher(id,teacher);
    }
    //查看教师信息
    public static Teacher[] findAllTeacher() {
        //调用库管类中的findAllTeacher方法返回保存教师信息的容器
        return TeacherDao.findAllTeacher();
    }
}
